package edu.uprm.ece.icom4035.polynomial;

import java.util.Iterator;

public interface Polynomial extends Iterable<Term> {
	
	/**
	 * Adds two polynomials together
	 * @param P2 polynomial to be added
	 * @return the sum of polynomials
	 */
	public Polynomial add(Polynomial P2);
	
	/**
	 * Subtract two polynomials
	 * @param P2 polynomial to be subtracted
	 * @return difference of the polynomials
	 */
	public Polynomial subtract(Polynomial P2);
	
	/**
	 * Multiplies two polynomials
	 * @param P2 polynomial to be multiplied
	 * @return product of both polynomials
	 */
	public Polynomial multiply(Polynomial P2);
	
	/**
	 * Multiplies polynomial by a value
	 * @param c value to be multiplied to polynomial
	 * @return result of polynomial multiplied by the value c
	 */
	public Polynomial multiply(double c);

	/**
	 * Calculates the derivative of the polynomial
	 * @return derivative of the polynomial
	 */
	public Polynomial derivative();
	
	/**
	 * Calculates the indefinite integral of the polynomial
	 * @return indefinite integral of the polynomial
	 */
	public Polynomial indefiniteIntegral();
	
	/**
	 * Calculates the definite integral of a polynomial between two points
	 * @param a initial point
	 * @param b final point
	 * @return definite integral of the polynomial
	 */
	public double definiteIntegral(double a, double b);
	
	/**
	 * Gets the highest degree of the polynomial
	 * @return highest degree of the polynomial
	 */
	public int degree();
	
	/**
	 * Evaluates the polynomial with the given value
	 * @param x value to evaluate the polynomial
	 * @return value of the evaluation of the polynomial
	 */
	public double evaluate(double x);

	/**
	 * Checks if both polynomials are the same
	 * @param P polynomial to check equality
	 * @return true or false
	 */
	boolean equals(Polynomial P);

}
